/**
 * This file is part of the CAKIS project.
 * 
 * Copyright (c) 2009-2010 - Florian Arndt, Christian Kerl
 * 
 * @license GNU Lesser General Public License v3 <http://www.opensource.org/licenses/lgpl-3.0.html>
 * @since   26.04.2010
 * @version SVN: $Id: ProductList.java 115 2010-05-09 12:30:12Z christian-kerl@web.de $
 */
package org.cakis.server.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

import org.hibernate.validator.NotNull;

/**
 * ProductList
 *
 * @author Christian Kerl
 */
@Entity
@EntityListeners(TimestampableListener.class)
public class ProductList implements Timestampable, Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;
    private Integer version;

    private Date createdAt;
    private Date updatedAt;

    private String name;
    private Boolean isArchived = false;

    private List<ProductListEntry> entries = new ArrayList<ProductListEntry>();

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Version
    public Integer getVersion() {
        return version;
    }

    @SuppressWarnings("unused")
    private void setVersion(Integer version) {
        this.version = version;
    }

    @NotNull
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getIsArchived() {
        return isArchived;
    }

    public void setIsArchived(Boolean isArchived) {
        this.isArchived = isArchived;
    }

    @OneToMany(mappedBy = "productList", cascade = { CascadeType.ALL })
    //@JoinColumn(name = "productList_id")
    //@IndexColumn(name = "entries_idx")
    public List<ProductListEntry> getEntries() {
        return entries;
    }

    public void setEntries(List<ProductListEntry> entries) {
        this.entries = entries;
    }

    @Temporal(TemporalType.DATE)
    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    @Temporal(TemporalType.DATE)
    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }
}
